<?php
/**
 * Created by PhpStorm.
 * User: sosyuki
 * Date: 2018/5/15
 * Time: 10:30
 */

namespace Drupal\distribution\MetadataController;


use EntityDefaultMetadataController;

class DistributionMetadataController extends EntityDefaultMetadataController {

  public function entityPropertyInfo() {
    $info = parent::entityPropertyInfo();
    $properties = &$info[$this->type]['properties'];

    $properties['user'] = [
      'label' => t('用户'),
      'type' => 'user',
      'schema field' => 'uid',
      'description' => t('用户.'),
    ];
    $properties['parent'] = [
      'label' => t('上家'),
      'type' => 'user',
      'schema field' => 'pid',
      'description' => t('上家.'),
    ];
    $properties['team'] = [
      'label' => t('团队'),
      'type' => 'user',
      'schema field' => 'tid',
      'description' => t('团队.'),
    ];

    $properties['child_count'] = [
      'label' => t("下家数量"),
      'getter callback' => 'entity_property_getter_method',
      'type' => 'integer',
    ];
    $properties['created'] = [
      'label' => t('记录时间'),
      'type' => 'date',
      'schema field' => 'created',
      'description' => t('记录时间.'),
    ];
    $properties['changed'] = [
      'label' => t('最近变更时间'),
      'type' => 'date',
      'schema field' => 'changed',
      'description' => t('最近变更时间.'),
    ];
    return $info;
  }
}
